package com.cloud.platform.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fuminwang
 * @Title: DocumentationConfig
 * @Package com.cloud.platform
 * @Description: 资源配置
 * @date 2018/11/7下午5:31
 */
@Component
@Primary
public class DocumentationConfig implements SwaggerResourcesProvider {
    @Override
    public List<SwaggerResource> get() {
        List resources = new ArrayList<>();
        resources.add(swaggerResource("用户服务", "/api/v1/user/v2/api-docs", "1.0"));
        resources.add(swaggerResource("权限服务", "/api/v1/authority/v2/api-docs", "1.0"));
        resources.add(swaggerResource("点评服务", "/api/v1/dp/v2/api-docs", "1.0"));
        resources.add(swaggerResource("后台backend服务", "/api/v1/backend/v2/api-docs", "1.0"));
        return resources;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }

}
